<?php 
define('_VIEW_MODEL_','admin');
session_start();
$statu = $_SESSION['statu'];
$helpinfo = "";
require_once("../init.php");
if(!$statu){
	echo "<script>window.parent.location.href='./index.php'</script>";
}
if(isset($act)&&$act=="add"){
	//echo "insert into {$telper}help set `title` = '$helpname',`content`='$word',`column` = '$helpstyle',`rank` = '$helprank',`state` = '$helpsta'";
	//exit;
	$db->Execute("insert into {$telper}help set `title` = '$helpname',`content`='$word',`column` = '$hestyle',`rank` = '$helprank',`state` = '$helpsta'");
	header("Location:help.php"); 
	exit;
}
if(isset($act)&&$act=="edithelp"){
	//echo "update {$telper}help set `title` = '$helpname',`content`='$word',`column` = '$hestyle',`rank` = '$helprank',`state` = '$helpsta' where `id` ='$helpid'";
	//exit;
	$db->Execute("update {$telper}help set `title` = '$helpname',`content`='$word',`column` = '$hestyle',`rank` = '$helprank',`state` = '$helpsta' where `id` ='$helpid'");
	header("Location:help.php");	
	exit;
}
if(isset($act)&&$act=="edit"){
$id = intval($id);
	$helpinfo = $db->GetRow("select * from {$telper}help where `id` = '$id'");
	if(empty($helpinfo)){
		echo "<script>window.parent.location.href='./index.php'</script>";
		exit;	
	}	
	$adminhelpname = $adminhelpedit;
	$act = "edithelp";
	$helpid = $id;
	$content = $helpinfo['content'];
}else{
	$adminhelpname = $adminhelpadd;
	$act = "add";
	$helpid = "";
	$content = "";
}
include("fckeditor/fckeditor.php");
$oFCKeditor = new FCKeditor('word') ;
$oFCKeditor->BasePath ='fckeditor/';
$oFCKeditor->Value	= "$content";
$oFCKeditor ->Width ="800";
$oFCKeditor ->Height='400'; 					
$fckeditor = $oFCKeditor->Createhtml() ;
$smartyObj->assign('title',$admintitle);
$smartyObj->assign('helpinfo',$helpinfo);
$smartyObj->assign('adminhelpname',$adminhelpname);
$smartyObj->assign('fckeditor',$fckeditor);
$smartyObj->assign('act',$act);
$smartyObj->assign('helpstyle',$helpstyle);
$smartyObj->assign('helpid',$helpid);
$smartyObj->display("helpadd.tpl");
?>